<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');
?>
<script>
function get_program(){
    var tahun = $("#tahun").val();
	$.ajax({
        url: "<?=base_url();?>index.php/pencarian/get_program/",
        global: false,
        type: "POST",
        async: false,
        dataType: "html",
        data: "tahun="+tahun, //the name of the $_POST variable and its value
        success: function (response) //'response' is the output provided by the controller method prova()
        {
                       //counts the number of dynamically generated options
                       var dynamic_options = $("*").index( $('.dynamic')[0] );
                    //removes previously dynamically generated options if they exists (not equal to 0)
						if ( dynamic_options != (-1)) $(".dynamic").remove();
                    $("#program").html(response);
                    $(".first").attr({selected: ' selected'});
					
                   }
                   
	});
	return false
}

function get_sasaran_prog(){
    var program = $("#program").val();
	$.ajax({
        url: "<?=base_url();?>index.php/pencarian/get_sasaran_program/",
        global: false,
        type: "POST",
        async: false,
        dataType: "html",
        data: "program="+program, //the name of the $_POST variable and its value
        success: function (response) //'response' is the output provided by the controller method prova()
        {
                       //counts the number of dynamically generated options
                       var dynamic_options = $("*").index( $('.dynamic')[0] );
                    //removes previously dynamically generated options if they exists (not equal to 0)	
                    $("#sasaran_prog").html(response);
                    $(".first").attr({selected: ' selected'});
                   }                
	});
	return false
}

function get_indikator_prog(){
    var sasaran_prog = $("#sasaran_prog").val();
	$.ajax({
        url: "<?=base_url();?>index.php/pencarian/get_indikator_program/",
        global: false,
        type: "POST",
        async: false,
        dataType: "html",
        data: "sasaran_prog="+sasaran_prog, //the name of the $_POST variable and its value
        success: function (response) //'response' is the output provided by the controller method prova()
        {
                       //counts the number of dynamically generated options
                       var dynamic_options = $("*").index( $('.dynamic')[0] );
                    //removes previously dynamically generated options if they exists (not equal to 0)
                    $("#indikator_prog").html(response);
                    $(".first").attr({selected: ' selected'});
					
                   }
                   
	});
	return false
}
function get_kegiatan(){
    var program = $("#program").val();
	$.ajax({
        url: "<?=base_url();?>index.php/pencarian/get_kegiatan/",
        global: false,
        type: "POST",
        async: false,
        dataType: "html",
        data: "program="+program, //the name of the $_POST variable and its value
        success: function (response) //'response' is the output provided by the controller method prova()
        {
                       //counts the number of dynamically generated options
                       var dynamic_options = $("*").index( $('.dynamic')[0] );
                    //removes previously dynamically generated options if they exists (not equal to 0)	
                    $("#kegiatan").html(response);
                    $(".first").attr({selected: ' selected'});
                   }              
	});
	return false
}
function get_sasaran_keg(){
    var kegiatan = $("#kegiatan").val();
	$.ajax({
        url: "<?=base_url();?>index.php/pencarian/get_sasaran_keg/",
        global: false,
        type: "POST",
        async: false,
        dataType: "html",
        data: "kegiatan="+kegiatan, //the name of the $_POST variable and its value
        success: function (response) //'response' is the output provided by the controller method prova()
        {
                       //counts the number of dynamically generated options
                       var dynamic_options = $("*").index( $('.dynamic')[0] );
                    //removes previously dynamically generated options if they exists (not equal to 0)	
                    $("#sasaran_keg").html(response);
                    $(".first").attr({selected: ' selected'});
                   }                
	});
	return false
}

function get_indikator_keg(){
    var sasaran_keg = $("#sasaran_keg").val();
	$.ajax({
        url: "<?=base_url();?>index.php/pencarian/get_indikator_keg/",
        global: false,
        type: "POST",
        async: false,
        dataType: "html",
        data: "sasaran_keg="+sasaran_keg, //the name of the $_POST variable and its value
        success: function (response) //'response' is the output provided by the controller method prova()
        {
                       //counts the number of dynamically generated options
                       var dynamic_options = $("*").index( $('.dynamic')[0] );
                    //removes previously dynamically generated options if they exists (not equal to 0)
                    $("#indikator_keg").html(response);
                    $(".first").attr({selected: ' selected'});
					
                   }
                   
	});
	return false
}

function count_persen(){

	var volume = document.form_input_real_indikator.volume.value;
	var target = document.form_input_real_indikator.target.value;
	var persen = volume/target*100;
	
	document.form_input_real_indikator.persen.value = persen;

}// end of function
</script>
<!-- JavaScript -->
<script type="text/javascript" src="<?= base_url() ?>js/wufoo.js"></script>
<!-- CSS -->
<link rel="stylesheet" type="text/css" href="<?= base_url() ?>css/form/form.css" media="screen, tv, projection" title="Default" />
<link rel="stylesheet" type="text/css" href="<?php echo base_url() ?>css/datepicker.css" media="screen, tv, projection" title="Default" />
<script type="text/javascript" src="<?= base_url() ?>js/datepicker.js"></script>

<div id="container">
	<?
    //Setting Awal Value Jika Prosedur yang dilakukan adalah prosedur input biasa.
	foreach($anggaran->result() as $row){
			$value['id_anggaran'] = $row->IDANGGARAN;
			$value['tahun'] = $row->TAHUN;
		}
		$value['legend'] = "Form Pencarian Data";
		$value['info'] = "Form pencarian data";
		$value['act_form'] = "pencarian/cek";
	//end if
	
	?>
	<?= form_open($value["act_form"],'class="wufoo" name="form_program"'); ?>
	<fieldset class="fieldset">
	<legend class="legend">
		<?= $value["legend"] ?> |
	</legend>
	
	<div class="info">
		<div><?= $value["info"] ?></div>
	</div>
	<div>
		<?= anchor(site_url(''),img(array('src'=>'images/main/38.png','border'=>'0','alt'=>'')).' Kembali ke menu utama','Menampilkan halaman menu utama'); ?>
	</div>
 <!-- Konten -------------------------------------------------------------------------->
 <div id="contentform">
	<ul>
		
		<li>
                    <label class="desc">Tahun Anggaran</label>
                        <div>
                            <select id="tahun" name="tahun" class="small-input" onchange="get_program()">
                        <option value="0">-- Pilih Tahun Anggaran --</option>
                        <?php foreach($anggaran->result() as $row){
										echo '<option value="'.$row->IDANGGARAN.'">'.$row->TAHUN.'</option>';
									} ?>
                      </select>
                        </div>
                    <p class="instruct">
                            Pilih Tahun Anggaran Pada Kolom ini.			
                    </p>
                </li>

                <?php echo form_error('tahun'); ?>
		
		
		<li>
                    <label class="desc">Program</label>
                        <div>
                        <select id="program" name="program" onchange="get_sasaran_prog(),get_kegiatan(), get_indikator_prog(), get_sasaran_keg(),get_indikator_keg()">
                        <option value="0">-- Pilih Semua --</option>
                      </select>
                        </div>
                    <p class="instruct">
                            Pilih Program Pada Kolom ini.			
                    </p>
                </li>
                <?php echo form_error('program'); ?>
		
		<li>
                    <label class="desc">Sasaran Strategis (Program)</label>
                        <div>
                        <select id="sasaran_prog" name="sasaran_prog" onchange="get_indikator_prog()">
                        <option value="0">-- Pilih Semua --</option>
                      </select>
                        </div>
                    <p class="instruct">
                            Pilih Sasaran Strategis (Program) Pada Kolom ini.			
                    </p>
                </li>
                <?php echo form_error('sasaran_prog'); ?>
			
		<li>
                    <label class="desc">Indikator Kinerja(Program)</label>
                        <div>
                        <select id="indikator_prog" name="indikator_prog" >
                        <option value="0">-- Pilih Semua --</option>
                      </select>
                        </div>
                    <p class="instruct">
                            Pilih Indikator Kinerja(Program) Pada Kolom ini.			
                    </p>
                </li>
                <?php echo form_error('indikator_prog'); ?>
				
		<li>
			<label class="desc">Target Indikator(Program)</label>
			<div>
			
			<select name="nilai_prog_ind">
				<option value="1">>=</option>
				<option value="2">=</option>
				<option value="3"><=</option>
			</select>
				<input  type="text" maxlength="255" size="12" name="target_prog" value="0"/> 
			</div>
			<p class="instruct">
				Masukkan Target Indikator(Program) Pada Kolom ini.			
			</p>
		</li>
		<?php echo form_error('target_prog'); ?>
		
		
		<li>
			<label class="desc">Realisasi Indikator(Program)</label>
			<div>
			
			<select name="nilai_prog_real">
				<option value="1">>=</option>
				<option value="2">=</option>
				<option value="3"><=</option>
			</select>
				<input  type="text" maxlength="255" size="12" name="real_prog" value="0"/> 
			</div>
			<p class="instruct">
				Masukkan Realisasi Indikator(Program) Pada Kolom ini.			
			</p>
		</li>
		<?php echo form_error('real_prog'); ?>
			
<li>
                    <label class="desc">Kegiatan</label>
                        <div>
                        <select id="kegiatan" name="kegiatan" onchange="get_sasaran_keg(),get_indikator_keg()">
                        <option value="0">-- Pilih Semua --</option>
                      </select>
                        </div>
                    <p class="instruct">
                            Pilih Kegiatan Pada Kolom ini.			
                    </p>
                </li>
                <?php echo form_error('kegitan'); ?>
		
		<li>
                    <label class="desc">Sasaran Strategis (Kegiatan)</label>
                        <div>
                        <select id="sasaran_keg" name="sasaran_keg" onchange="get_indikator_keg()">
                        <option value="0">-- Pilih Semua --</option>
                      </select>
                        </div>
                    <p class="instruct">
                            Pilih Sasaran Strategis (Kegiatan) Pada Kolom ini.			
                    </p>
                </li>
                <?php echo form_error('sasaran_keg'); ?>
			
		<li>
                    <label class="desc">Indikator Kinerja(Kegiatan)</label>
                        <div>
                        <select id="indikator_keg" name="indikator_keg" >
                        <option value="0">-- Pilih Semua --</option>
                      </select>
                        </div>
                    <p class="instruct">
                            Pilih Indikator Kinerja(Kegiatan) Pada Kolom ini.			
                    </p>
                </li>
                <?php echo form_error('indikator_keg'); ?>
				
		<li>
			<label class="desc">Target Indikator(Kegiatan)</label>
			<div>
			
			<select name="nilai_keg_ind">
				<option value="1">>=</option>
				<option value="2">=</option>
				<option value="3"><=</option>
			</select>
				<input  type="text" maxlength="255" size="12" name="target_keg" value="0"/> 
			</div>
			<p class="instruct">
				Masukkan Target Indikator(Kegiatan) Pada Kolom ini.			
			</p>
		</li>
		<?php echo form_error('target_keg'); ?>
		
		
		<li>
			<label class="desc">Realisasi Indikator(Kegiatan)</label>
			<div>
			
			<select name="nilai_keg_real">
				<option value="1">>=</option>
				<option value="2">=</option>
				<option value="3"><=</option>
			</select>
				<input  type="text" maxlength="255" size="12" name="real_keg" value="0"/> 
			</div>
			<p class="instruct">
				Masukkan Realisasi Indikator(Kegiatan) Pada Kolom ini.			
			</p>
		</li>
		<?php echo form_error('real_keg'); ?>
		
		<li class="buttons">
		  <input id="saveForm" class="btTxt" type="submit" value="Cari" />
		  <input name="submit" type="reset" value="Batal" />
		</li>
	</ul>
</div>
</fieldset>
<?= form_close(); ?>
</form>
</div><!--container-->